home *** CD-ROM | disk | FTP | other *** search
- #include "MPDialogs.h"
- #include "DD.h"
-
- /* Display a dialog which displays the values of the dialog items
- * stored by the multi-pane dialog code
- */
- void DialogDisplay(Handle theData)
- {
- DialogPtr dlog;
- short itemHit;
- EventRecord theEvent;
- DialogPtr whichDlog;
- GrafPtr oldPort;
-
- if (!(dlog = GetNewDialog(500, NULL, (WindowPtr) -1))) return;
- GetPort(&oldPort);
- SetPort(dlog);
- TextFont(geneva);
- ShowWindow(dlog);
-
- do {
- if(!GetNextEvent(everyEvent, &theEvent)) continue;
- if(!IsDialogEvent(&theEvent)) continue;
- (void) DialogSelect(&theEvent, &whichDlog, &itemHit);
-
- // Update the display of the dialog.
- if (theEvent.what == updateEvt && whichDlog == dlog)
- DoUpdate(dlog, theData);
-
- // If the user changed views, set it up for redraw
- if (itemHit == 2)
- InvalRect(&dlog->portRect);
- } while (itemHit != 1);
-
- DisposeDialog(dlog);
- SetPort(oldPort);
- }
-
- /* Draw the dialog's contents.
- */
- void DoUpdate(DialogPtr dlog, Handle theData)
- {
- short i, iType, pane, val, err;
- Handle iHandle;
- Rect iRect;
- Str255 theStr;
-
- pane = GetDItemValue(dlog, 2);
- for(i=0; i<12; i++) {
- // Draw item number
- GetDItem(dlog, i*2+3, &iType, &iHandle, &iRect);
- NumToString(i+1, theStr);
- TextBox(&theStr[1], theStr[0], &iRect, 0);
-
- // Draw value of the item, or a message if an error was returned
- GetDItem(dlog, i*2+4, &iType, &iHandle, &iRect);
- if (err = GetMPDItem(theData, pane, i+1, (char *) &val, sizeof(short))) {
- // Handle that string preference
- if (err == keWrongSize) {
- long lval;
- if (!(err = GetMPDItem(theData, pane, i+1, (char *) &lval, sizeof(long)))) {
- NumToString(lval, theStr);
- } else if (err == keWrongSize) {
- err = GetMPDItem(theData, pane, i+1, (char *) theStr, sizeof(Str255));
- }
- }
- switch(err) {
- case keNullData:
- Pstrcpy(theStr, "\pNull Ptr!");
- break;
- case keBadPane:
- Pstrcpy(theStr, "\pBad Pane");
- break;
- case keBadItem:
- Pstrcpy(theStr, "\pBad Item");
- break;
- case keWrongSize:
- Pstrcpy(theStr, "\pWrong Size");
- break;
- }
- } else NumToString(val, theStr);
- TextBox(&theStr[1], theStr[0], &iRect, 0);
- }
- }
-